#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GCCMakros.h"

#define CLASSCONST      1
#define CLASSVAR        2
#define CLASSSTRUCT     3
#define CLASSFUNC       4
#define CLASSREG        5

#define FORMINT         1
#define FORMBOOL        2
#define FORMCHAR        3
#define FORMARRAY       4
#define FORMSTRUCT      5
#define FORMFUNC        6


struct SymTab ptr bottom;
struct SymTab ptr top;
int height;

/* Symbol Table */
struct SymTab
{
    struct Object ptr head;
    struct Object ptr tail;
    struct SymTab ptr lower;
    int length;
};

struct Object
{
    char          ptr name;
    int               oClass;
    struct Type   ptr type;
    struct Object ptr next;
    int               val;
    int               pointer;
};

struct Type
{
    int               form;     //the DataType
    int               len;      //length only for arrays
    int               size;     //maybe for address calculation
    struct SymTab ptr fields;   //the fields of a struct
    struct Type   ptr base;     //the baseType of a Array
};

//the basic Types
struct Type ptr intType;
struct Type ptr boolType;
struct Type ptr charType;

//Stack functions
function initSymTabStack();
function push(struct SymTab ptr symTab);
struct Object ptr search(char ptr name);
function pop();
function clearSymTabStack();

//SymTab Functions
function initSubSymTab(struct SymTab ptr symTab);
function initSymTab(struct SymTab ptr symTab);
function add(struct SymTab ptr symTab,
             char          ptr name,
             int               oClass,
             struct Type   ptr Type,
             int               val);

function addObj(struct SymTab ptr symTab,
                struct Object ptr node);
function printSymTable();
function printObj(struct Object ptr object);
struct Object ptr getByName(struct SymTab ptr symTab, char ptr name);
function deleteByName(struct SymTab ptr symTab, char ptr name);
function deleteList(struct SymTab ptr symTab);

//function addField(struct Type ptr structType, struct Object ptr field);
function printType(struct Type ptr type);
